package com.vogue.supplymall.shop.domain.mapper;

import com.vogue.ssm.database.util.SqlLangDriver;
import com.vogue.supplymall.shop.domain.model.OrganShopImg;

import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * The interface Organ shop img mapper.
 *
 * @Aouthor: zhangliang
 * @Date: Create in 2017-12-12
 */
@Mapper
public interface OrganShopImgMapper extends BaseMapper<OrganShopImg, Long> {
    /**
     * Find by id shop.
     *
     * @param sysCode the sys code
     * @return the shop
     */
    @Select("SELECT osi.id, osi.createdate, osi.modifydate, osi.syscodeid, osi.imgtype, osi.imgurl, osi.organid " +
            "FROM organ_shop_img osi WHERE osi.syscodeid = #{arg0} and organid = #{arg1}")
    @Lang(SqlLangDriver.class)
    public List<OrganShopImg> findBySysCode(Long sysCode, Long organid);
    
    /**
     * 根据syscodeid和organtype得到企业图片，如果店铺没有图片，就用企业图片
     */
    @Select("SELECT osi.id, osi.createdate, osi.modifydate, osi.syscodeid, osi.imgtype, osi.imgurl, osi.organid " +
            "FROM organ_shop_img osi WHERE osi.syscodeid = #{sysCode} and organtype = 0")
    @Lang(SqlLangDriver.class)
    public List<OrganShopImg> findEntImgBySysCode(Long sysCode);
    
}
